package  
{
	import flash.display.GraphicsPathWinding;
	import flash.display.Sprite;
	import flash.utils.getTimer;
	
	/**
	 * ...
	 * @author Chen Ran
	 */
	public class GraphicsTest extends Sprite 
	{
		
		public function GraphicsTest() 
		{
			const count:int = 100000;
			
			var i:int;
			var timer:uint;
			
			
			timer = getTimer();
			for (i = 0; i < count; ++i)
			{
				drawEvenOdd();
			}
			trace('drawEvenOdd:', getTimer() - timer);
			
			
			timer = getTimer();
			for (i = 0; i < count; ++i)
			{
				drawNonZero();
			}
			trace('drawNonZero:', getTimer() - timer);
		}
		
		private function drawEvenOdd():void
		{
			graphics.beginFill(0x003366);
			graphics.drawPath(GraphicsData.star_commands, GraphicsData.star_coord, GraphicsPathWinding.EVEN_ODD);
			graphics.endFill();
			graphics.clear();
		}
		
		private function drawNonZero():void
		{
			graphics.beginFill(0x003366);
			graphics.drawPath(GraphicsData.star_commands, GraphicsData.star_coord, GraphicsPathWinding.NON_ZERO);
			graphics.endFill();
			graphics.clear();
		}
		
	}

}

class GraphicsData
{
	internal static const star_commands:Vector.<int> = new Vector.<int>(5, true);
    {
			star_commands[0] = 1;
			star_commands[1] = 2;
			star_commands[2] = 2;
			star_commands[3] = 2;
			star_commands[4] = 2;
	}
			
	internal static const star_coord:Vector.<Number> = new Vector.<Number>(10, true);
	{
			star_coord[0] = 66; //x
			star_coord[1] = 10; //y 
			star_coord[2] = 23; 
			star_coord[3] = 127; 
			star_coord[4] = 122; 
			star_coord[5] = 50; 
			star_coord[6] = 10; 
			star_coord[7] = 49; 
			star_coord[8] = 109; 
			star_coord[9] = 127;
	}
}
